package b1w1nn1ng.crossf1t.tests;
import b1w1nn1ng.crossf1t.business.*;
import b1w1nn1ng.crossf1t.db.*;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Date;

import junit.framework.TestCase;

import org.junit.*;
import static org.junit.Assert.*;

public class TestWorkout extends TestCase{
	public static final int USER_ID = 1;
	public Workout workout1; //Tabata
	public Workout workout2; //AMRAP
	public Workout workout3; //Timed
	
	protected void setUp() {
		//initialize 3 workout objects.
		Exercise exercise;
		Exercise [] ex;
		Calendar cal = Calendar.getInstance();
		Date d = new Date();
		cal.setTime(d);
		exercise = new Exercise("Push-ups", 0, 10, 0, d);
		ex = new Exercise[1];
		ex[0] = exercise;
		workout1 = new Tabata(USER_ID, 10, ex, true, cal);
		
		ex = new Exercise[2];
		ex[0] = new Exercise("Pull-ups", 0, 15, 0, d);
		ex[1] = new Exercise("L-sit", 0, 1, 0, d);
		try {
			workout2 = new AMRAP(USER_ID, 15, 5, ex, true, cal);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
		ex = new Exercise[6];
		ex[0] = new Exercise("Thruster", 95, 21, 0, d);
		ex[2] = new Exercise("Thruster", 95, 15, 0, d);
		ex[4] = new Exercise("Thruster", 95, 9, 0, d);
		ex[1] = new Exercise("Pull-ups", 0, 21, 0, d);
		ex[3] = new Exercise("Pull-ups", 0, 15, 0, d);
		ex[5] = new Exercise("Pull-ups", 0, 9, 0, d);
		cal.add(Calendar.DATE, 1); //set calendar to tomorrows date
		double time = 3.56;
		int [] reps = {21, 15, 9};
		int [] sets = {1};
		try {
			workout3 = new Timed(USER_ID, time, reps, sets, true, cal);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} //will use fran as a timed example
		
		//2 of the 3 workout objects will have the same date. 
		//All other information should be the same
		
		//initialize a workout object that has all empty fields or null (referred to as "empty workout")
		Workout emptyWorkout = new Tabata(0, 0, null, false, null);
		//except still has a user
	}

	public void testAddWorkout() {

		//add a workout to the database corresponding to a user and a date
		
		//check that the workout is in the database.
		
		//get information from the database for that workout
		//and make sure it is the same information that was input
		
		
		
		//add another workout to the same user and a different date
		
		//check that the 2nd workout is in the database
		
		//get information for the 2nd workout and make sure it corresponds to
		//the information for the 2nd workout
		
		
		
		
		//add another workout to the same user and the same date as one of the above
		//check that there is an error/returns false or null (can only have 1 workout per day)
		
		
		
		
		
		//add a workout to a different user on the same date.
		
		//check that the workout is in the database
		
		//get information and make sure it corresponds to that workout.
		
		
		
		//add the empty workout 
		
		//check that the workout is in the database
		
		//get information and make sure it corresponds to that workout.
	}
	
	public void testDeleteWorkout()
	{
		//try to delete a workout that doesn't exist
		
		//make sure that there is an error/nothing bad happens
		
		
		//add a workout
		//delete that workout
		//make sure the workout is deleted
		
		
		//add 3 workouts
		//delete the 2nd workout
		//make sure the 2nd workout is deleted and the other 2 workouts are not affected
	}
}
